$(document).ready(function() {
    
    /**
    *** CAC HAM VIET RIENG  
    ***/
    
    //
    // ==== Lay tham so tu trinh duyet
    $.extend({
        getUrlVars: function(){
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for(var i = 0; i < hashes.length; i++){
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        },
        getUrlVar: function(name){
            return $.getUrlVars()[name];
        }
    });
    // End function extend
    
    // 
    // === Cho phep hien, an cac chuc nangn cua gmap trong wweb site
    paramSelect = $.getUrlVar('fn');
    
    if(paramSelect !=null){
        switch(paramSelect){
            case 'drag': {
                $('.dir-route').hide();
            }
            break;
        }                
    }
    
    
    //An form tìm ki?m nang cao
    $("#advance_search").hide();
    $("#ads").click(function(){
        $("#advance_search").slideToggle(600);
    });
    //
    //LOGIN
    $("#loginform").hide();
    $("#buttondangnhap").click(function(){
        $("#loginform").slideToggle(600);
    });
    
    //        
    //khi hover QUA NUT ADVANCE SEARCH (TIM KIEM NANG CAO)        
    $("#ads").hover(function(){
       $this = $(this);
       $this.attr("value","Tìm kiếm mở rộng").css({width: '120px', height: '25px'});//"width","120px" 
    },function(){
        $this = $(this);
        $this.attr("value","...").css("width","30px"); 
    });

    //
    // == MO RONG BAN DO MAP KHI HOVER
    $('#map_canvas').hover(function(){        
        $(this).css({
                    width: '785px !important',
                    left: '-173 !important'
                });
                                
    },function(){
        $(this).css('width',500).css('left',0);
        
    })
        // == END 
        
        /*
        $('.getMap').click(function(){
            $.ajax({
               type: "GET",
               url: "Helpers/getLocation.php?d=16" , 
               context: document.body,
               success: function(data){
                   // $("#mainnaviright").load("Helpers/map.php");    
               }                           
            });
             
        });
        */
        //
        // VALIDATE FORM
        //$(".validate-search").validate();
        
        // == VALIDATE TIM DUONG
        $('.validatesearch').validate();
        
       
       
        
});
   
  